﻿// -----------------------------------------------------------
//
// Root.cs
//
// During Global Game Jam Metz - 28/01/2012
//
// -----------------------------------------------------------

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Audio;
using System.Collections.Generic;

namespace GlobalGameJam
{
    class StartMenuScreen : AMenuScreen
    {

        public StartMenuScreen()
            : base("Start Menu")
        {
            MenuEntry exitMenuEntry = new MenuEntry("Exit");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");
            MenuEntry gameplayScreenEntry = new MenuEntry("Start Game");

            exitMenuEntry.Selected += OnCancel;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;
            gameplayScreenEntry.Selected += GameplayScreenEntrySelected;
            MenuEntries.Add(gameplayScreenEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(exitMenuEntry);
            name = "StartMenu";
        }

        protected override void OnCancel(PlayerIndex playerIndex)
        {
            const string message = "Sure you wanna stop playing ? :'(";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }

        void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
        }

        void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.Game.Exit();
        }

        void GameplayScreenEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            // a modif avec la classe Load
            ScreenManager.AddScreen(new GameplayScreen(), e.PlayerIndex);
        }
    }
}
